package com.example.serviceheadlines.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.serviceheadlines.service.HeadlinesService;
import com.tangyuan.dto.UpdateHeadlinesDto;
import com.tangyuan.feignapis.headlines.IHeadlinesFeignClient;
import com.tangyuan.model.Headlines;
import com.tangyuan.model.headlines.HeadlinesContentQueryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HeadlinesClient implements IHeadlinesFeignClient {

    @Autowired
    private HeadlinesService headersService;

    @GetMapping("/feignApi/headlines/searchArticle/{userId}/{name}/{pageNum}/{pageSize}")
    @Override
    public Page<Headlines> searchArticle(@PathVariable Long userId, @PathVariable String name, @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        HeadlinesContentQueryDto dto = new HeadlinesContentQueryDto(name);
        dto.setPageNum(pageNum);
        dto.setPageNum(pageSize);
        return headersService.searchHeadlines(userId,dto);
    }


    @GetMapping("/feignApi/headlines/getByHeadlinesId/{userId}/{headlinesId}")
    @Override
    public Headlines getByHeadlinesId(@PathVariable("userId") Long userId,@PathVariable("headlinesId") Long headlinesId) {
       return headersService.getHeadlinesById(headlinesId,userId);
    }


    @GetMapping("/feignApi/headlines/getMyHeadlinesByUserId/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Headlines> getMyHeadlinesByUserId(@PathVariable Long userId, @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        return headersService.getMyHeadlinesByUserId(userId, pageNum, pageSize);
    }

    @GetMapping("/feignApi/headlines/getArticleThumpNumByUserId/{userId}")
    @Override
    public Long getArticleThumpNumByUserId(@PathVariable Long userId) {
        return headersService.getArticleThumpNumByUserId(userId);
    }

    @GetMapping("/feignApi/headlines/getMyTrumpHeadlines/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Headlines> getMyTrumpHeadlines(@PathVariable Long userId,@PathVariable Integer pageNum,@PathVariable Integer pageSize) {
        return headersService.getMyTrumpHeadlines(userId, pageNum, pageSize);
    }

    @GetMapping("/feignApi/headlines/getMyCollectArticle/{userId}/{pageNum}/{pageSize}")
    @Override
    public List<Headlines> getMyCollectArticle(@PathVariable Long userId,@PathVariable Integer pageNum,@PathVariable Integer pageSize) {
        return headersService.getMyCollectArticle(userId, pageNum, pageSize);
    }

    @PostMapping("/feignApi/video/updateHeadlinesUserMessage")
    public void updateHeadlinesUserMessage(@RequestBody UpdateHeadlinesDto updateHeadlinesDto) {
        headersService.updateHeadlinesUserMessage(updateHeadlinesDto);
    }
}
